
import ViewManager from "../../engine/ViewManager";
import ResLoader from "../res/ResLoader";

import BaseModel from "./BaseModel";
import EventDispatcher from "../event/EventDispatcher";
import { UIIndex } from "../tools/Define";

export default class BaseController extends EventDispatcher {

    /**
     * 
     * @param prefab 
     * @param className 
     * @param model 
     * @param parent 
     * @param loader 
     * @param func 
     */
    addToParent(prefab: string, className: string, model: any, loader: ResLoader, parent: cc.Node, func?: Function) {
        ViewManager.instance().addToParent(prefab, className, this, model, loader, parent, func)
    }

    /**
      * 
      * @param prefab 
      * @param className 
      * @param model 
      * @param uiIndex 
      * @param loader 
      * @param func 
      */
    pushToast(prefab: string, className: string, model: any, loader: ResLoader, uiIndex: number = UIIndex.STACK, func?: Function) {
        ViewManager.instance().pushToast(prefab, className, this, model, loader, uiIndex, func)
    }

    /**
     * 
     * @param prefab 
     * @param className 
     * @param model 
     * @param uiIndex 
     * @param loader 
     * @param func 
     */
    pushView(prefab: string, className: string, model: any, loader: ResLoader, uiIndex: number = UIIndex.STACK, func?: Function) {
        ViewManager.instance().pushView(prefab, className, this, model, loader, uiIndex, func)
    }


    initView(node: any, name: string, model?: BaseModel) {
        return ViewManager.instance().initView(node, name, this, model)
    }



}
